Skip to content

Conversation

Hanssen0
Copy link
Member

Copy link

changeset-bot bot commented Sep 17, 2025

🦋 Changeset detected

Latest commit: 32b18a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 18 packages
Name Type
@ckb-ccc/core Major
@ckb-ccc/joy-id Minor
@ckb-ccc/eip6963 Patch
@ckb-ccc/lumos-patches Patch
@ckb-ccc/nip07 Patch
@ckb-ccc/okx Patch
@ckb-ccc/rei Patch
@ckb-ccc/shell Patch
@ckb-ccc/spore Patch
@ckb-ccc/ssri Patch
@ckb-ccc/udt Patch
@ckb-ccc/uni-sat Patch
@ckb-ccc/utxo-global Patch
@ckb-ccc/xverse Patch
@ckb-ccc/ccc Patch
ckb-ccc Patch
@ckb-ccc/connector Patch
@ckb-ccc/connector-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for liveccc ready!

Name Link
🔨 Latest commit 32b18a7
🔍 Latest deploy log https://app.netlify.com/projects/liveccc/deploys/68cd352775590200081acc32
😎 Deploy Preview https://deploy-preview-315--liveccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 22 (🟢 up 2 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for docsccc ready!

Name Link
🔨 Latest commit 32b18a7
🔍 Latest deploy log https://app.netlify.com/projects/docsccc/deploys/68cd35279e48b20008fd610d
😎 Deploy Preview https://deploy-preview-315--docsccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 61 (🔴 down 13 from production)
Accessibility: 88 (no change from production)
Best Practices: 92 (no change from production)
SEO: 92 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for apiccc ready!

Name Link
🔨 Latest commit 32b18a7
🔍 Latest deploy log https://app.netlify.com/projects/apiccc/deploys/68cd3527b40c70000817459d
😎 Deploy Preview https://deploy-preview-315--apiccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 82 (🔴 down 15 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (no change from production)
SEO: 94 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for appccc ready!

Name Link
🔨 Latest commit 32b18a7
🔍 Latest deploy log https://app.netlify.com/projects/appccc/deploys/68cd3527b5ac300008968c2b
😎 Deploy Preview https://deploy-preview-315--appccc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 45 (🔴 down 31 from production)
Accessibility: 89 (🟢 up 1 from production)
Best Practices: 92 (🔴 down 8 from production)
SEO: 100 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@Hanssen0 Hanssen0 force-pushed the feat-identity-address branch 3 times, most recently from a12b9a9 to a48e376 Compare September 18, 2025 11:46
@Hanssen0
Copy link
Member Author

/canary

Copy link
Contributor

🚀 Canary version published successfully! View workflow run

The following packages have been published to npm:

  • @ckb-ccc/ccc@0.0.0-canary-20250918121441
  • ckb-ccc@0.0.0-canary-20250918121441
  • @ckb-ccc/connector@0.0.0-canary-20250918121441
  • @ckb-ccc/connector-react@0.0.0-canary-20250918121441
  • @ckb-ccc/core@0.0.0-canary-20250918121441
  • @ckb-ccc/eip6963@0.0.0-canary-20250918121441
  • @ckb-ccc/joy-id@0.0.0-canary-20250918121441
  • @ckb-ccc/lumos-patches@0.0.0-canary-20250918121441
  • @ckb-ccc/nip07@0.0.0-canary-20250918121441
  • @ckb-ccc/okx@0.0.0-canary-20250918121441
  • @ckb-ccc/rei@0.0.0-canary-20250918121441
  • @ckb-ccc/shell@0.0.0-canary-20250918121441
  • @ckb-ccc/spore@0.0.0-canary-20250918121441
  • @ckb-ccc/ssri@0.0.0-canary-20250918121441
  • @ckb-ccc/udt@0.0.0-canary-20250918121441
  • @ckb-ccc/uni-sat@0.0.0-canary-20250918121441
  • @ckb-ccc/utxo-global@0.0.0-canary-20250918121441
  • @ckb-ccc/xverse@0.0.0-canary-20250918121441

@Hanssen0 Hanssen0 force-pushed the feat-identity-address branch from a48e376 to bc5a1a7 Compare September 18, 2025 14:41
@Hanssen0
Copy link
Member Author

/canary

Copy link
Contributor

🚀 Canary version published successfully! View workflow run

The following packages have been published to npm:

  • @ckb-ccc/ccc@0.0.0-canary-20250918144348
  • ckb-ccc@0.0.0-canary-20250918144348
  • @ckb-ccc/connector@0.0.0-canary-20250918144348
  • @ckb-ccc/connector-react@0.0.0-canary-20250918144348
  • @ckb-ccc/core@0.0.0-canary-20250918144348
  • @ckb-ccc/eip6963@0.0.0-canary-20250918144348
  • @ckb-ccc/joy-id@0.0.0-canary-20250918144348
  • @ckb-ccc/lumos-patches@0.0.0-canary-20250918144348
  • @ckb-ccc/nip07@0.0.0-canary-20250918144348
  • @ckb-ccc/okx@0.0.0-canary-20250918144348
  • @ckb-ccc/rei@0.0.0-canary-20250918144348
  • @ckb-ccc/shell@0.0.0-canary-20250918144348
  • @ckb-ccc/spore@0.0.0-canary-20250918144348
  • @ckb-ccc/ssri@0.0.0-canary-20250918144348
  • @ckb-ccc/udt@0.0.0-canary-20250918144348
  • @ckb-ccc/uni-sat@0.0.0-canary-20250918144348
  • @ckb-ccc/utxo-global@0.0.0-canary-20250918144348
  • @ckb-ccc/xverse@0.0.0-canary-20250918144348

@Hanssen0 Hanssen0 force-pushed the feat-identity-address branch from bc5a1a7 to 32b18a7 Compare September 19, 2025 10:49
@Hanssen0
Copy link
Member Author

/canary

Copy link
Contributor

🚀 Canary version published successfully! View workflow run

The following packages have been published to npm:

  • @ckb-ccc/ccc@0.0.0-canary-20250919105013
  • ckb-ccc@0.0.0-canary-20250919105013
  • @ckb-ccc/connector@0.0.0-canary-20250919105013
  • @ckb-ccc/connector-react@0.0.0-canary-20250919105013
  • @ckb-ccc/core@0.0.0-canary-20250919105013
  • @ckb-ccc/eip6963@0.0.0-canary-20250919105013
  • @ckb-ccc/joy-id@0.0.0-canary-20250919105013
  • @ckb-ccc/lumos-patches@0.0.0-canary-20250919105013
  • @ckb-ccc/nip07@0.0.0-canary-20250919105013
  • @ckb-ccc/okx@0.0.0-canary-20250919105013
  • @ckb-ccc/rei@0.0.0-canary-20250919105013
  • @ckb-ccc/shell@0.0.0-canary-20250919105013
  • @ckb-ccc/spore@0.0.0-canary-20250919105013
  • @ckb-ccc/ssri@0.0.0-canary-20250919105013
  • @ckb-ccc/udt@0.0.0-canary-20250919105013
  • @ckb-ccc/uni-sat@0.0.0-canary-20250919105013
  • @ckb-ccc/utxo-global@0.0.0-canary-20250919105013
  • @ckb-ccc/xverse@0.0.0-canary-20250919105013

@Hanssen0 Hanssen0 marked this pull request as ready for review October 21, 2025 02:45
@Hanssen0
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to create a Signer from a signature and includes the address in the JoyID identity. The changes are logical, but there are a few areas that could be improved for robustness and maintainability. Specifically, there are unsafe uses of JSON.parse that could lead to runtime errors, and some hardcoded URLs that should be extracted as constants. I've left specific comments on these points.

Comment on lines +20 to +29
const { address, publicKey, keyType } = JSON.parse(identity) as {
address: string;
publicKey: string;
keyType: string;
keyType: CredentialKeyType;
};
const signatureObj = JSON.parse(signature) as {
alg: SigningAlg;
signature: string;
message: string;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using JSON.parse with type assertions (as) is not type-safe. If the identity or signature strings are malformed or don't match the expected structure, this will throw an unhandled exception at runtime, which could crash the application. It's recommended to wrap these parsing operations in a try...catch block and validate the parsed objects to handle potential errors gracefully.

For example:

  let identityObj: { address: string; publicKey: string; keyType: CredentialKeyType; };
  let signatureObj: { alg: SigningAlg; signature: string; message: string; };

  try {
    identityObj = JSON.parse(identity);
    signatureObj = JSON.parse(signature);
  } catch {
    return false;
  }

  const { address, publicKey, keyType } = identityObj;
  if (!address || !publicKey || !keyType || !signatureObj.alg || !signatureObj.signature) {
    return false;
  }

Comment on lines +41 to +43
const { address } = JSON.parse(signature.identity) as {
address: string;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using JSON.parse with a type assertion is unsafe. If signature.identity is not valid JSON or doesn't contain an address property, this will cause a runtime error. It's important to handle this case to prevent the application from crashing.

Consider using a try...catch block and validating the parsed object:

      case SignerSignType.JoyId: {
        let address: string;
        try {
          const identity = JSON.parse(signature.identity);
          address = identity.address;
        } catch (e) {
          throw new Error(`Failed to parse JoyId identity: ${e}`);
        }
        if (!address) {
          throw new Error("Missing address in JoyId identity");
        }

        return new SignerCkbScriptReadonly(
          client,
          (await Address.fromString(address, client)).script,
        );
      }

Comment on lines +43 to +45
const registry = address.startsWith("ckb")
? "https://api.joy.id/api/v1/"
: "https://api.testnet.joyid.dev/api/v1/";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Hardcoding URLs directly within the function makes the code harder to maintain and test. If these URLs change, you'll have to find and replace them in the code. It would be better to extract these URLs into named constants at the module level. This improves readability and centralizes configuration.

Comment on lines +35 to +57
switch (signature.signType) {
case SignerSignType.EvmPersonal:
return new SignerEvmAddressReadonly(client, signature.identity);
case SignerSignType.BtcEcdsa:
return new SignerBtcPublicKeyReadonly(client, "", signature.identity);
case SignerSignType.JoyId: {
const { address } = JSON.parse(signature.identity) as {
address: string;
};
return new SignerCkbScriptReadonly(
client,
(await Address.fromString(address, client)).script,
);
}
case SignerSignType.NostrEvent:
return new SignerNostrPublicKeyReadonly(client, signature.identity);
case SignerSignType.CkbSecp256k1:
return new SignerCkbPublicKey(client, signature.identity);
case SignerSignType.DogeEcdsa:
return new SignerDogeAddressReadonly(client, signature.identity);
case SignerSignType.Unknown:
throw new Error("Unknown signer sign type");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The switch statement is missing a default case. If a new SignerSignType enum member is added in the future, it will fall through the switch, signer will be undefined, and signer.getAddresses() on line 59 will throw a TypeError. To make this more robust, you should add a default case to handle any unexpected signType values by throwing an error.

For example:

    switch (signature.signType) {
      // ... other cases
      default:
        throw new Error(`Unsupported sign type: ${signature.signType as string}`);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant